import React from 'react'
import {useSelector,useDispatch} from "react-redux"
import * as action from "../action/index.js"
function Funhook() {
 let store = useSelector((state)=>{ //useSelector 相当于类组件得mapStateToProps
    console.log(state,111111)
    return {
        ...state.hotReducer
    }
 })
 let dispatch = useDispatch() //替代类组件得mapDispatchToProps
 console.log(store)

 let changeName = ()=>{
     dispatch(action.setName("zhaoliu"))
 }
  return (
    <div>{store.name}
        <button onClick={()=>changeName()}>修改name</button>
    
    </div>
  )
}

export default Funhook